package com.cy.pj.module.controller;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;


@Controller
public class ModelViewController {

    @RequestMapping("/doModelAndView")
    public String doModelAndView(Model model){
        model.addAttribute("username","憨憨");
        model.addAttribute("state",true);
        return "default";
    }

    @RequestMapping("/doModelAndView03")
    public ModelAndView doModelAndView03(ModelAndView mv){
        List<String> list = new ArrayList<String>();
        list.add("北京");
        list.add("上海");
        list.add("广州");
        mv.addObject("cities",list);
        mv.setViewName("default");
        return mv;

    }

}
